#include <app\states\rotateState.h>
#include <app\states\statesFactory.h>

int rotateState::class_type_id = ROTATE_STATE_TYPE_ID;

REGISTER_STATE(ROTATE_STATE_TYPE_ID, rotateState);

sessionState *
rotateState::create() {
  return new rotateState();
} 

void 
rotateState::pickSharedRotation() {
  shared_rotation = new_rotation;
}

vec3f 
rotateState::getSharedRotation() const {
  return shared_rotation;
}

void 
rotateState::rotate(const float x, const float y, const float z) {

  new_rotation = vec3f(x, y, z);
  rotated = (new_rotation != shared_rotation);

  //std::cout << "rotate: " << x << " " << y << " " << z << endl;
  if (rotated) rotate_sig(x, y, z);
}


void 
rotateState::addRotateObserver(rotateObserver *ref) {
  rotate_sig.connect(boost::bind(&rotateObserver::rotate, ref, _1 , _2, _3));
}

int
rotateState::getClassTypeId() {
  return rotateState::class_type_id;
}

int
rotateState::getTypeId() {
  return type_id;
}

rotateState::rotateState() : type_id(ROTATE_STATE_TYPE_ID), rotated(false) {

}

rotateState::~rotateState() {

}